package com.caldremch.myhttp;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.caldremch.myhttp.model.BaseRespData;
import com.caldremch.myhttp.model.CommonConfigResp;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class MainActivity extends AppCompatActivity {

    private String TAG = "hzx";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        findViewById(R.id.tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                RetrofitHelper.getsApiService()
                        .getCommConfig(new BaseReqData())
                        .subscribeOn(Schedulers.io())
                        .observeOn(AndroidSchedulers.mainThread())
                        .subscribe(new BaseObserver<CommonConfigResp>() {
                            @Override
                            protected void onSuccess(BaseRespData<CommonConfigResp> respData, CommonConfigResp data) throws Exception {
                                Log.e(TAG, "onNext"+data.companyName);
                            }

                            @Override
                            protected void onFailure(BaseRespData<CommonConfigResp> respData, Throwable e) throws Exception {
                                if (e != null){
                                    e.printStackTrace();
                                }
                            }
                        });


            }
        });

    }
}
